import React, { Component } from 'react'
import { View, Text, Image } from '@tarojs/components'
import { AtAvatar, AtIcon, AtList, AtListItem } from 'taro-ui'
import Taro from '@tarojs/taro';
import './myIndex.less'
import TabBar from "../common/taBar";
// import patientManagement from "./patientManagement/patientManagement";
import { IMGURL, APIBASEURL } from "../constants/global";
//我的 主页
export default class Index extends Component {
  state = {//内置变量
    name: 'zhangsan',
    userIcon: '',
    loginName: '登录/注册'

  }

  // 生命周期
  componentWillMount() {



  }//第一次渲染之前，只执行一次

  componentDidMount() {
  }//第一次渲染之后，只执行一次

  componentWillUnmount() {
  }//卸载之前，只执行一次

  componentDidShow() {

    Taro.getStorage({
      key: '__userInfo__',
      success: result => {
        this.setState({ loginName: result.data.username })
        console.log("用户：",result.data);
        Taro.setStorage({
          key:'__itemcode__',
          data:result.data.itemcode,
          success:result=>{
            console.log("itemcode：",result);
          }
        })
      }
    })

  }//页面显示时候触发

  componentDidHide() {
  }//页面隐藏时候触发
  
  // shouldComponentUpdate(nextProps, nextState) {//更改即将发生时候执行
  //   if (nextState.name == 'lisi')
  //     return true
  //   else
  //     return false;//表示该更改state变量的动作失效
  // }
  //跳转到我的挂号
  toMyRegistration() {
    Taro.navigateTo({ url: '/pages/myRegistration/index' })
  }
  //跳转到就诊人管理
  toPatientManagement() {
    Taro.navigateTo({ url: '/pages/patientManagement/index' })

  }
  //跳转到健康档案
  toMyHealthRecord() {
    Taro.navigateTo({ url: '/pages/myRecord/healthRecords/index' })
  }
  //跳转到电子病历
  toMyMedicalRecord() {
    Taro.navigateTo({ url: '/pages/myRecord/medicalRecords/index' })
  }
  //跳转到就诊费用
  toMyMedicalExpenses() {
    Taro.navigateTo({ url: '/pages/myRecord/medicalExpenses/index' })
  }
  //跳转到效果评价
  toMyTreatmentEffectEvaluation() {
    Taro.navigateTo({ url: '/pages/treatmentEffectEvaluation/index' })
  }

  //跳转到体质辨识记录
  toMyPhysicalRecords() {
    Taro.navigateTo({ url: '/pages/physicalRecords/index' })
  }
  //跳转到登录
  toLogin() {
    Taro.navigateTo({ url: '/pages/WXLogin/wxLogin' })
  }





  render() {
    return (
      <view className='wrapper'>
        {/*封面*/}
        <view className='header'>
          <view>
            <View className='at-row at-row__justify--between myTop'>
              <View className='at-col at-col-3   mygua'>
                {/*头像*/}
                <AtAvatar circle image={IMGURL + 'my/favicon.ico'} />

              </View>
              <View className='at-col at-col-6 username' onClick={this.toLogin.bind(this)}>
                {/*名字*/}
                <Text > {this.state.loginName} </Text>

              </View>
              <View className='at-col  at-col-2'>
                {/*箭头*/}
                <AtIcon value='chevron-right' color='#FFF'     ></AtIcon>
              </View>
            </View>
          </view>
          {/*图标*/}
          <view>
            {/*我的挂号/我的就诊人*/}
            <View className='at-row myCard'>
              <View className='at-col mygua line_right' onClick={this.toMyRegistration.bind(this)}>
                <Image className='myRegister' src={IMGURL + 'my/u1227.svg'} />
                <Text className='text-center'>我的挂号</Text>
              </View>
              <View className='at-col mygua ' onClick={this.toPatientManagement.bind(this)}>
                <Image className='myRegister' src={IMGURL + 'my/u1230.svg'} />
                <Text className='text-center'>就诊人管理</Text>
              </View>
            </View>
          </view>
        </view>

        <view>
          <view className='card-date'>
            <view>
              <Text className='text-tip'>健康数据</Text>
              <View className='at-row  myCard-center'>
                <View className='at-col mygua' onClick={this.toMyHealthRecord.bind(this)} >
                  <Image className='myRegister' src={IMGURL + 'my/u1251.svg'} />
                  <Text className='text-center txtmargin'>健康档案</Text>
                </View>
                <View className='at-col mygua' onClick={this.toMyMedicalRecord.bind(this)}>
                  <Image className='myRegister' src={IMGURL + 'my/u1252.svg'} />
                  <Text className='text-center txtmargin'>电子病历</Text>
                </View>
                <View className='at-col mygua' onClick={this.toMyMedicalExpenses.bind(this)}>
                  <Image className='myRegister' src={IMGURL + 'my/u1253.svg'} />
                  <Text className='text-center txtmargin'>就诊费用</Text>
                </View>
              </View>
            </view>
          </view>
        </view>

        <view >
          <view className='card-list'>
            {/*我的服务*/}
            <Text className='text-bottom-tip'>我的服务</Text>
            <AtList className='card-bottom' >
              <AtListItem title='我的收藏' arrow='right' thumb={IMGURL + 'my/u1237.svg'} />
              <AtListItem title='效果评价' arrow='right' thumb={IMGURL + 'my/u1248.svg'} onClick={this.toMyTreatmentEffectEvaluation.bind(this)} />
              <AtListItem title='体质辨识记录' arrow='right' thumb={IMGURL + 'my/u1243.svg'} onClick={this.toMyPhysicalRecords.bind(this)} />
            </AtList>
          </view>
        </view>

        <TabBar tabBarCurrent={3} />
      </view>

    )
  }
}
